<template>
    <div class="app-container">
        <h3> {{ categoryName }} </h3>
        <el-divider></el-divider>
        <customer :productIds="productIds" v-if="type=='customer'"></customer>
        <supplier :productIds="productIds" v-else-if="type=='supplier'"></supplier>
    </div>
</template>
<script>
import CryptoJS from 'crypto-js';
import Customer from './components/customer';
import Supplier from './components/supplier';
export default {
    name:"index",
    data(){
        return {
            type:"",
            productIds:[],
            categoryName: ""
        }
    },
    components: {
        Customer,
        Supplier
    },
    created(){
        this.init()
    },
    methods:{
        init(){
            let keys = this.$route.query.key;
            var words = CryptoJS.enc.Base64.parse(keys);
            let res = words.toString(CryptoJS.enc.Utf8);
            let productIds = JSON.parse(res)
            let type = CryptoJS.enc.Base64.parse(this.$route.query.type).toString(CryptoJS.enc.Utf8)
            this.$set( this, 'productIds', productIds )
            this.$set( this, 'type', type )
            this.$set( this, 'categoryName', this.$route.query.categoryName )
        }
    }
}
</script>